package java_DesignPattern.BehavioralPattern.InterpreterPattern;

/**
 * 变量类
 */
public class Variable extends AbstractExpression {

     private String name;

    // 构造方法
    public Variable(String name) {
        this.name = name;
    }

    @Override
    public int interpret(Context context) {
        return context.get(name);
    }

     // 变量的字符串表示
    @Override
    public String toString() {
        return name;
    }
}
